<%@page isELIgnored="false"%>
<link rel="stylesheet" type="text/css" href="/static/css/page/page.css">


<script language="javascript">    
 
 	function paginationSkipTo(toUrl,referenceId) {
	 	var referenceTextBox = (document.getElementById) ? document.getElementById(referenceId)
                                   : document.all[referenceId];
      var reg=/\d/;
      try {
      	if (referenceTextBox == null || referenceTextBox.value.length==0){
	      	alert("<fmt:message key='page.skip.alert.empty'/>");
      		return;
      	}
      } catch(e){
      		alert("<fmt:message key='page.skip.alert.empty'/>");
       		return;
      }
      var isNumber = reg.exec(referenceTextBox.value);
      if (!isNumber) {
      	alert("<fmt:message key='page.skip.alert.number'/>");
      	return;
      }
      var number = 1;
       try {
       		number = parseInt(referenceTextBox.value,10);
       } catch(e){
       		alert("<fmt:message key='page.skip.alert.exception'/>");
       		return;
       }
       if (number<1){
       	alert("<fmt:message key='page.skip.alert.small'/>");
       	return;
       }
       if (number>"<c:out value='${pagination.totalPages}'/>"){
       	alert("<fmt:message key='page.skip.alert.big'/>");
       	return;
       }
       window.location=toUrl+number;
 	}
    
    function pagination_onkeypress(toUrl) {

    
    	if (window.event.keyCode==13){
    
    		paginationSkipTo(toUrl,'skipPageNumberTextBox');
    	} 
    }
 </script>
 
<div class="pages">
	<c:if test="${pagination.currentPage <= 1}">
		<a><fmt:message key="page.first" /></a>
	</c:if>
	<c:if test="${pagination.currentPage > 1}">
		<a href="<c:out value='${firstUrl}'/>"><fmt:message
				key="page.first" /> </a>
	</c:if>

	<c:if test="${pagination.currentPage <= 1}">
		<a><fmt:message key="page.before" /></a>
	</c:if>
	<c:if test="${pagination.currentPage > 1}">
		<a href="<c:out value='${previousUrl}'/>"> <fmt:message
				key="page.before" />
		</a>
	</c:if>

	<c:if test="${pagination.currentPage < pagination.totalPages}">
		<a href="<c:out value='${nextUrl}'/>"> <fmt:message
				key="page.after" /> </a>
	</c:if>
	<c:if test="${pagination.currentPage == pagination.totalPages}">
		<a><fmt:message key="page.after" /></a>
	</c:if>

	<c:if test="${pagination.currentPage < pagination.totalPages}">
		<a href="<c:out value='${lastUrl}'/>"><fmt:message key="page.last" />
		</a>
	</c:if>
	<c:if test="${pagination.currentPage == pagination.totalPages}">
		<a><fmt:message key="page.last" /></a>
	</c:if>


	<s class="pagesNum" ><fmt:message key="page.yeci" />
	<c:out value='${pagination.currentPage}' />
	/
	<c:out value='${pagination.totalPages}' />
	<s class="pagesNum" ><fmt:message key="page.skip.page" />
	<fmt:message key="page.yegongyou" />
	<c:out value='${pagination.totalRows}' />
	<fmt:message key="page.tiao" />
	<c:out value='${pagination.numPerPage}'/>
	<fmt:message key="page.tiaoye" />
	</s>
	
	<c:if test="${pagination.totalPages > 1}">
		<fmt:message key="page.skip.number" />
		<a class="pagesInput">
		<input type="text" name="skipPageNumberTextBox"
			id="skipPageNumberTextBox" value="" maxlength=4 size=2
			onkeypress="return pagination_onkeypress('<c:out value="${skipToUrl}"/>')">
		</a>
		<fmt:message key="page.skip.page" />
		<a
			href="javascript:paginationSkipTo('<c:out value="${skipToUrl}"/>','skipPageNumberTextBox')">
			<fmt:message key="page.skip.to" />
		</a>
	</c:if>
	
</div>



